/* eslint-disable no-unused-expressions */
// const remote = require('@electron/remote')

type State = Record<string, any>

// 无法在渲染进程中对其赋值
export const appShared = {
  token: 'default value',
  name: 'default value',
  password: 'default value'
}

function callState (app: Electron.App) {
  return {
    ...appShared,
    version: app.getVersion()
  }
}

function initGlobalState (app: Electron.App) {
  global.appShared = callState(app)
}

export function setGlobalState (data: State) {
  global.appShared = Object.assign(appShared, data)
}

export default initGlobalState
